package timer;

import graphicalInterface.HomeInterface;

import java.io.IOException;
import java.util.ArrayList;

import dataBaseInteraction.DataProcessing;

import main.ReadAuxFile;
import main.CreateScenarioPersons;
import main.CreateHome;
import main.Simulator;

/**
 * Clasa ce citeste scenariul si modifica valorile senzorilor in functie de actiunile
 * din scenariu.
 *
 */
public class MainTimer implements java.io.Serializable,TimerListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int i,n;
	ReadAuxFile aux;

	//consum curent de la ora la ora
	ArrayList<Float> consum_curent=new ArrayList<Float>();
	ArrayList<Integer> ora_sf=new ArrayList<Integer>();
	ArrayList<Integer> min_sf=new ArrayList<Integer>();
	ArrayList<Integer> sec_sf=new ArrayList<Integer>();
	ArrayList<String> ceFoloseste=new ArrayList<String>();
	String cameraBec=null;

	//consum apa de la ora la ora
	ArrayList<Float> consum_apa=new ArrayList<Float>();
	ArrayList<String> cameraConsum=new ArrayList<String>();
	ArrayList<Integer> ora_sfarsit=new ArrayList<Integer>();
	ArrayList<Integer> min_sfarsit=new ArrayList<Integer>();
	ArrayList<Integer> sec_sfarsit=new ArrayList<Integer>();
	ArrayList<String> ceSpala=new ArrayList<String>();

	//consum gaz de la ora la ora (gateste)
	ArrayList<Float> ultima_gaz=new ArrayList<Float>();
	ArrayList<Integer> ora_sf_gaz=new ArrayList<Integer>();
	ArrayList<Integer> min_sf_gaz=new ArrayList<Integer>();
	ArrayList<Integer> sec_sf_gaz=new ArrayList<Integer>();

	//consum curent instantaneu (seteaza)
	ArrayList<Float> ultima_curent=new ArrayList<Float>();

	//consum apa instantaneu (bea)
	ArrayList<Float> ultima_apa=new ArrayList<Float>();
	ArrayList<String> ultima_camera=new ArrayList<String>();

	//consum gaz instantaneu (seteaza aragaz)
	float ultim_gaz=0;

	//mananca
	int ora_sf_mancare=-1;
	int min_sf_mancare=-1;
	int sec_sf_mancare=-1;
	
	//aer conditionat foloseste
	int ora_aer=-1;
	int min_aer=-1;
	int sec_aer=-1;
	
	//masina de spalat foloseste
	int ora_masina=-1;
	int min_masina=-1;
	int sec_masina=-1;
	String cameraOmulet=null;

	boolean aer_conditionat=false;

	/*Constructor */
	public MainTimer() {
		aux=new ReadAuxFile();
		i=0;
		try {
			aux.citire();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		n=aux.lines.size();
	}
	
	/**
	 * returneaza camera in care se afla locuitorul
	 */
	public String getPersonsRoom(String omulet)
	{
		String camera=null;
		if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
			camera=CreateScenarioPersons.omulet1.getPozitie();
		else
			if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
				camera=CreateScenarioPersons.omulet2.getPozitie();
			else
				if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
					camera=CreateScenarioPersons.omulet3.getPozitie();
				else
					if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
						camera=CreateScenarioPersons.omulet4.getPozitie();
		return camera;
	}
	
	/**
	 * trezeste locuitorul
	 */
	public void wakeUp(String omulet)
	{
		if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
			CreateScenarioPersons.omulet1.setDoarme(false);
		else
			if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
				CreateScenarioPersons.omulet2.setDoarme(false);
			else
				if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
					CreateScenarioPersons.omulet3.setDoarme(false);
				else
					if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
						CreateScenarioPersons.omulet4.setDoarme(false);
		String camera=getPersonsRoom(omulet);
		if (camera.equalsIgnoreCase("dormitor1"))
		{

			Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
		}
		else
			if (camera.equalsIgnoreCase("dormitor2"))
				Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
			else
				if (camera.equalsIgnoreCase("dormitor3"))
					Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
	}
	
	/**
	 * culca locuitorul
	 */
	public void goToSleep(String omulet)
	{
		if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
			CreateScenarioPersons.omulet1.setDoarme(true);
		else
			if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
				CreateScenarioPersons.omulet2.setDoarme(true);
			else
				if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
					CreateScenarioPersons.omulet3.setDoarme(true);
				else
					if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
						CreateScenarioPersons.omulet4.setDoarme(true);
		String camera=getPersonsRoom(omulet);
		if (camera.equalsIgnoreCase("dormitor1"))
		{

			Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		}
		else
			if (camera.equalsIgnoreCase("dormitor2"))
				Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
			else
				if (camera.equalsIgnoreCase("dormitor3"))
					Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
	}
	
	/**
	 * muta locatarul in camera ceruta
	 */
	public void goToRoom(String omulet,ArrayList<String> camere)
	{
		for (int index=0; index<camere.size(); index++)
		{
			if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
			{
				CreateScenarioPersons.omulet1.setPozitie(camere.get(index));
			}
			else
				if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
				{
					CreateScenarioPersons.omulet2.setPozitie(camere.get(index));		
				}
				else
					if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
					{
						CreateScenarioPersons.omulet3.setPozitie(camere.get(index));				
					}
					else
						if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
						{
							CreateScenarioPersons.omulet4.setPozitie(camere.get(index));
						}
			modifyMovementSensor(camere.get(index));

		}
	}
	
	/**
	 * schimba valoarea senzorului de miscare potrivit
	 */
	public void modifyMovementSensor(String camera)
	{
		if (camera.equalsIgnoreCase("bucatarie"))
			Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
		else
			if (camera.equalsIgnoreCase("baie1"))
				Simulator.senzorMiscareBaie1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
			else
				if (camera.equalsIgnoreCase("baie2"))
					Simulator.senzorMiscareBaie2.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
				else
					if (camera.equalsIgnoreCase("living"))
						Simulator.senzorMiscareLiving.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
					else
						if (camera.equalsIgnoreCase("dormitor1"))
							Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
						else
							if (camera.equalsIgnoreCase("dormitor2"))
								Simulator.senzorMiscareDormitor2.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
							else
								if (camera.equalsIgnoreCase("dormitor3"))
									Simulator.senzorMiscareDormitor3.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
								else
									if (camera.equalsIgnoreCase("hol"))
										Simulator.senzorMiscareHol.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
	}
	
	/**
	 * seteaza starea becului din camera ceruta
	 */
	public void setLamp(String camera,boolean stare)
	{
		if (camera.equalsIgnoreCase("bucatarie"))
			CreateHome.casa.becBuc.setStare(stare);
		else
			if (camera.equalsIgnoreCase("baie1"))
				CreateHome.casa.becB1.setStare(stare);
			else
				if (camera.equalsIgnoreCase("baie2"))
					CreateHome.casa.becB2.setStare(stare);
				else
					if (camera.equalsIgnoreCase("living"))
						CreateHome.casa.becL.setStare(stare);
					else
						if (camera.equalsIgnoreCase("hol"))
							CreateHome.casa.BecH.setStare(stare);
						else
							if (camera.equalsIgnoreCase("dormitor1"))
								CreateHome.casa.BecD1.setStare(stare);
							else
								if (camera.equalsIgnoreCase("dormitor2"))
									CreateHome.casa.BecD2.setStare(stare);
								else
									if (camera.equalsIgnoreCase("dormitor3"))
										CreateHome.casa.BecD3.setStare(stare);
	}
	/**
	 * adauga coordonatele destinatie de pe interfata locuitorului
	 */
	public void goOnInterface (ArrayList<Integer> xx, ArrayList<Integer> yy,String omulet)
	{
		for (int i=0; i<xx.size();i++)
		{
			if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
			{
				HomeInterface.xDestOmulet1.add(xx.get(i));
				HomeInterface.yDestOmulet1.add(yy.get(i));
			}
			else
				if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
				{
					HomeInterface.xDestOmulet2.add(xx.get(i));
					HomeInterface.yDestOmulet2.add(yy.get(i));	
				}
				else
					if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
					{
						HomeInterface.xDestOmulet3.add(xx.get(i));
						HomeInterface.yDestOmulet3.add(yy.get(i));				
					}
					else
						if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
						{
							HomeInterface.xDestOmulet4.add(xx.get(i));
							HomeInterface.yDestOmulet4.add(yy.get(i));
						}
		}
	}
	
	/**
	 * pozitioneaza locuitorul in cadrul camerei pe interfata grafica
	 */
	public void positionPersonaInRoom(String camera, String omulet)
	{
		if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
		{
			if (camera.equalsIgnoreCase("bucatarie"))
			{
				HomeInterface.xDestOmulet1.add(100);
				HomeInterface.yDestOmulet1.add(200);
				
			}
			else
				if (camera.equalsIgnoreCase("baie2"))
				{
					HomeInterface.xDestOmulet1.add(50);
					HomeInterface.yDestOmulet1.add(400);
				}
				else
					if (camera.equalsIgnoreCase("living"))
					{
						HomeInterface.xDestOmulet1.add(50);
						HomeInterface.yDestOmulet1.add(600);
					}
					else
						if (camera.equalsIgnoreCase("baie1"))
						{
							HomeInterface.xDestOmulet1.add(450);
							HomeInterface.yDestOmulet1.add(650);
						}
						else
							if (camera.equalsIgnoreCase("dormitor1"))
							{
								HomeInterface.xDestOmulet1.add(850);
								HomeInterface.yDestOmulet1.add(650);
							}
							else
								if (camera.equalsIgnoreCase("dormitor2"))
								{
									HomeInterface.xDestOmulet1.add(800);
									HomeInterface.yDestOmulet1.add(350);
								}
								else
									if (camera.equalsIgnoreCase("dormitor3"))
									{
										HomeInterface.xDestOmulet1.add(750);
										HomeInterface.yDestOmulet1.add(100);
									}
									else
										if (camera.equalsIgnoreCase("hol"))
										{
											HomeInterface.xDestOmulet1.add(350);
											HomeInterface.yDestOmulet1.add(200);
										}
		}
		else
			if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
			{
				if (camera.equalsIgnoreCase("bucatarie"))
				{
					HomeInterface.xDestOmulet2.add(50);
					HomeInterface.yDestOmulet2.add(200);
					
				}
				else
					if (camera.equalsIgnoreCase("baie2"))
					{
						HomeInterface.xDestOmulet2.add(50);
						HomeInterface.yDestOmulet2.add(450);
					}
					else
						if (camera.equalsIgnoreCase("living"))
						{
							HomeInterface.xDestOmulet2.add(100);
							HomeInterface.yDestOmulet2.add(600);
						}
						else
							if (camera.equalsIgnoreCase("baie1"))
							{
								HomeInterface.xDestOmulet2.add(500);
								HomeInterface.yDestOmulet2.add(650);
							}
							else
								if (camera.equalsIgnoreCase("dormitor1"))
								{
									HomeInterface.xDestOmulet2.add(900);
									HomeInterface.yDestOmulet2.add(650);
								}
								else
									if (camera.equalsIgnoreCase("dormitor2"))
									{
										HomeInterface.xDestOmulet2.add(850);
										HomeInterface.yDestOmulet2.add(350);
									}
									else
										if (camera.equalsIgnoreCase("dormitor3"))
										{
											HomeInterface.xDestOmulet2.add(800);
											HomeInterface.yDestOmulet2.add(100);
										}
										else
											if (camera.equalsIgnoreCase("hol"))
											{
												HomeInterface.xDestOmulet2.add(400);
												HomeInterface.yDestOmulet2.add(200);
											}
			}
			else
				if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
				{
					if (camera.equalsIgnoreCase("bucatarie"))
					{
						HomeInterface.xDestOmulet3.add(150);
						HomeInterface.yDestOmulet3.add(50);
						
					}
					else
						if (camera.equalsIgnoreCase("baie2"))
						{
							HomeInterface.xDestOmulet3.add(100);
							HomeInterface.yDestOmulet3.add(450);
						}
						else
							if (camera.equalsIgnoreCase("living"))
							{
								HomeInterface.xDestOmulet3.add(150);
								HomeInterface.yDestOmulet3.add(600);
							}
							else
								if (camera.equalsIgnoreCase("baie1"))
								{
									HomeInterface.xDestOmulet3.add(550);
									HomeInterface.yDestOmulet3.add(650);
								}
								else
									if (camera.equalsIgnoreCase("dormitor1"))
									{
										HomeInterface.xDestOmulet3.add(800);
										HomeInterface.yDestOmulet3.add(700);
									}
									else
										if (camera.equalsIgnoreCase("dormitor2"))
										{
											HomeInterface.xDestOmulet3.add(850);
											HomeInterface.yDestOmulet3.add(400);
										}
										else
											if (camera.equalsIgnoreCase("dormitor3"))
											{
												HomeInterface.xDestOmulet3.add(850);
												HomeInterface.yDestOmulet3.add(100);
											}
											else
												if (camera.equalsIgnoreCase("hol"))
												{
													HomeInterface.xDestOmulet3.add(450);
													HomeInterface.yDestOmulet3.add(200);
												}			
				}
				else
					if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
					{
						if (camera.equalsIgnoreCase("bucatarie"))
						{
							HomeInterface.xDestOmulet4.add(50);
							HomeInterface.yDestOmulet4.add(150);
							
						}
						else
							if (camera.equalsIgnoreCase("baie2"))
							{
								HomeInterface.xDestOmulet4.add(150);
								HomeInterface.yDestOmulet4.add(450);
							}
							else
								if (camera.equalsIgnoreCase("living"))
								{
									HomeInterface.xDestOmulet4.add(200);
									HomeInterface.yDestOmulet4.add(600);
								}
								else
									if (camera.equalsIgnoreCase("baie1"))
									{
										HomeInterface.xDestOmulet4.add(500);
										HomeInterface.yDestOmulet4.add(600);
									}
									else
										if (camera.equalsIgnoreCase("dormitor1"))
										{
											HomeInterface.xDestOmulet4.add(750);
											HomeInterface.yDestOmulet4.add(700);
										}
										else
											if (camera.equalsIgnoreCase("dormitor2"))
											{
												HomeInterface.xDestOmulet4.add(750);
												HomeInterface.yDestOmulet4.add(350);
											}
											else
												if (camera.equalsIgnoreCase("dormitor3"))
												{
													HomeInterface.xDestOmulet4.add(850);
													HomeInterface.yDestOmulet4.add(150);
												}
												else
													if (camera.equalsIgnoreCase("hol"))
													{
														HomeInterface.xDestOmulet4.add(500);
														HomeInterface.yDestOmulet4.add(200);
													}
					}
	}
	
	/**
	 * actiunea merge
	 */
	public void go(int i,String omulet)
	{
		String camera=getPersonsRoom(omulet);
		String atribut=aux.getAttribute(i);
		ArrayList<Integer> xx=new ArrayList<Integer>();
		ArrayList<Integer> yy=new ArrayList<Integer>();
		if (camera.equalsIgnoreCase("bucatarie"))
		{
			if (atribut.equalsIgnoreCase("baie2"))
			{
				ArrayList<String> camere=new ArrayList<String>();
				camere.add("bucatarie");
				camere.add("hol");
				camere.add("baie2");
				goToRoom(omulet,camere);
				xx.add(150);
				yy.add(150);
				xx.add(350);
				yy.add(150);
				xx.add(350);
				yy.add(400);
				xx.add(150);
				yy.add(400);
				
				goOnInterface(xx, yy, omulet);
				positionPersonaInRoom("baie2", omulet);

			}
			else
				if (atribut.equalsIgnoreCase("living"))
				{
					ArrayList<String> camere=new ArrayList<String>();
					camere.add("bucatarie");
					camere.add("hol");
					camere.add("living");
					goToRoom(omulet,camere);
					xx.add(150);
					yy.add(150);
					xx.add(350);
					yy.add(150);
					xx.add(350);
					yy.add(650);
					
					goOnInterface(xx, yy, omulet);
					positionPersonaInRoom("living", omulet);
				}
				else
					if (atribut.equalsIgnoreCase("baie1"))
					{
						ArrayList<String> camere=new ArrayList<String>();
						camere.add("bucatarie");
						camere.add("hol");
						camere.add("baie1");
						goToRoom(omulet,camere);
						xx.add(150);
						yy.add(150);
						xx.add(500);
						yy.add(150);
						xx.add(500);
						yy.add(650);
						
						goOnInterface(xx, yy, omulet);
						positionPersonaInRoom("baie1", omulet);
					}
					else
						if (atribut.equalsIgnoreCase("dormitor1"))
						{
							ArrayList<String> camere=new ArrayList<String>();
							camere.add("bucatarie");
							camere.add("hol");
							camere.add("dormitor2");
							camere.add("dormitor1");
							goToRoom(omulet,camere);
							xx.add(150);
							yy.add(150);
							xx.add(500);
							yy.add(150);
							xx.add(500);
							yy.add(400);
							xx.add(800);
							yy.add(400);
							xx.add(800);
							yy.add(650);
							
							goOnInterface(xx, yy, omulet);
							positionPersonaInRoom("dormitor1", omulet);
						}
						else
							if (atribut.equalsIgnoreCase("dormitor2"))
							{
								ArrayList<String> camere=new ArrayList<String>();
								camere.add("bucatarie");
								camere.add("hol");
								camere.add("dormitor2");
								goToRoom(omulet,camere);	
								xx.add(150);
								yy.add(150);
								xx.add(500);
								yy.add(150);
								xx.add(500);
								yy.add(400);
								xx.add(800);
								yy.add(400);
								
								goOnInterface(xx, yy, omulet);
								positionPersonaInRoom("dormitor2", omulet);
							}
							else
								if (atribut.equalsIgnoreCase("dormitor3"))
								{
									ArrayList<String> camere=new ArrayList<String>();
									camere.add("bucatarie");
									camere.add("hol");
									camere.add("dormitor3");
									goToRoom(omulet,camere);
									xx.add(150);
									yy.add(150);
									xx.add(500);
									yy.add(150);
									xx.add(800);
									yy.add(150);
									
									goOnInterface(xx, yy, omulet);
									positionPersonaInRoom("dormitor3", omulet);
								}

								else
									if (atribut.equalsIgnoreCase("hol"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("bucatarie");
										camere.add("hol");
										goToRoom(omulet,camere);
										xx.add(150);
										yy.add(150);
										xx.add(500);
										yy.add(150);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("hol", omulet);
									}
		}
		else
			if(camera.equalsIgnoreCase("baie2"))
			{
				if (atribut.equalsIgnoreCase("bucatarie"))
				{
					ArrayList<String> camere=new ArrayList<String>();
					camere.add("baie2");
					camere.add("hol");
					camere.add("bucatarie");
					goToRoom(omulet,camere);
					xx.add(150);
					yy.add(400);
					xx.add(350);
					yy.add(400);
					xx.add(350);
					yy.add(150);
					xx.add(150);
					yy.add(150);
					
					goOnInterface(xx, yy, omulet);
					positionPersonaInRoom("bucatarie", omulet);
				}
				else
					if (atribut.equalsIgnoreCase("living"))
					{
						ArrayList<String> camere=new ArrayList<String>();
						camere.add("baie2");
						camere.add("hol");
						camere.add("living");
						goToRoom(omulet,camere);
						xx.add(150);
						yy.add(400);
						xx.add(350);
						yy.add(400);
						xx.add(350);
						yy.add(650);
						
						goOnInterface(xx, yy, omulet);
						positionPersonaInRoom("living", omulet);
					}
					else
						if (atribut.equalsIgnoreCase("baie1"))
						{

							ArrayList<String> camere=new ArrayList<String>();
							camere.add("baie2");
							camere.add("hol");
							camere.add("baie1");
							goToRoom(omulet,camere);
							xx.add(150);
							yy.add(400);
							xx.add(500);
							yy.add(400);
							xx.add(500);
							yy.add(650);
							
							goOnInterface(xx, yy, omulet);
							positionPersonaInRoom("baie1", omulet);
						}
						else
							if (atribut.equalsIgnoreCase("dormitor1"))
							{
								ArrayList<String> camere=new ArrayList<String>();
								camere.add("baie2");
								camere.add("hol");
								camere.add("dormitor2");
								camere.add("dormitor1");
								goToRoom(omulet,camere);
								xx.add(150);
								yy.add(400);
								xx.add(500);
								yy.add(400);
								xx.add(800);
								yy.add(400);
								xx.add(800);
								yy.add(650);
								
								goOnInterface(xx, yy, omulet);
								positionPersonaInRoom("dormitor1", omulet);
							}
							else
								if (atribut.equalsIgnoreCase("dormitor2"))
								{
									ArrayList<String> camere=new ArrayList<String>();
									camere.add("baie2");
									camere.add("hol");
									camere.add("dormitor2");
									goToRoom(omulet,camere);
									xx.add(150);
									yy.add(400);
									xx.add(500);
									yy.add(400);
									xx.add(800);
									yy.add(400);
									
									goOnInterface(xx, yy, omulet);
									positionPersonaInRoom("dormitor2", omulet);
								}
								else
									if (atribut.equalsIgnoreCase("dormitor3"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("baie2");
										camere.add("hol");
										camere.add("dormitor3");
										goToRoom(omulet,camere);
										xx.add(150);
										yy.add(400);
										xx.add(350);
										yy.add(400);
										xx.add(350);
										yy.add(150);
										xx.add(800);
										yy.add(150);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("dormitor3", omulet);
									}
									else
										if (atribut.equalsIgnoreCase("hol"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("baie2");
											camere.add("hol");
											goToRoom(omulet,camere);
											xx.add(150);
											yy.add(400);
											xx.add(350);
											yy.add(400);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("hol", omulet);
										}
			}
			else
				if (camera.equalsIgnoreCase("living"))
				{
					if(atribut.equalsIgnoreCase("baie2"))
					{
						ArrayList<String> camere=new ArrayList<String>();
						camere.add("living");
						camere.add("hol");
						camere.add("baie2");
						goToRoom(omulet,camere);
						xx.add(350);
						yy.add(650);
						xx.add(350);
						yy.add(400);
						xx.add(150);
						yy.add(400);
						
						goOnInterface(xx, yy, omulet);
						positionPersonaInRoom("baie2", omulet);
					}
					else
						if (atribut.equalsIgnoreCase("bucatarie"))
						{
							ArrayList<String> camere=new ArrayList<String>();
							camere.add("living");
							camere.add("hol");
							camere.add("bucatarie");
							goToRoom(omulet,camere);
							xx.add(350);
							yy.add(650);
							xx.add(350);
							yy.add(150);
							xx.add(150);
							yy.add(150);
							
							goOnInterface(xx, yy, omulet);
							positionPersonaInRoom("bucatarie", omulet);
						}
						else
							if (atribut.equalsIgnoreCase("baie1"))
							{
								ArrayList<String> camere=new ArrayList<String>();
								camere.add("living");
								camere.add("baie1");
								goToRoom(omulet,camere);
								xx.add(350);
								yy.add(650);
								xx.add(500);
								yy.add(650);
								
								goOnInterface(xx, yy, omulet);
								positionPersonaInRoom("baie1", omulet);
							}
							else
								if (atribut.equalsIgnoreCase("dormitor1"))
								{
									ArrayList<String> camere=new ArrayList<String>();
									camere.add("living");
									camere.add("baie1");
									camere.add("dormitor1");
									goToRoom(omulet,camere);
									xx.add(350);
									yy.add(650);
									xx.add(500);
									yy.add(650);
									xx.add(800);
									yy.add(650);
									
									goOnInterface(xx, yy, omulet);
									positionPersonaInRoom("dormitor1", omulet);
								}
								else
									if (atribut.equalsIgnoreCase("dormitor2"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("living");
										camere.add("hol");
										camere.add("dormitor2");
										goToRoom(omulet,camere);
										xx.add(350);
										yy.add(650);
										xx.add(350);
										yy.add(400);
										xx.add(800);
										yy.add(400);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("dormitor2", omulet);
										
									}
									else
										if (atribut.equalsIgnoreCase("dormitor3"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("living");
											camere.add("hol");
											camere.add("dormitor3");
											goToRoom(omulet,camere);
											xx.add(350);
											yy.add(650);
											xx.add(350);
											yy.add(150);
											xx.add(800);
											yy.add(150);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("dormitor3", omulet);
										}
										else
											if (atribut.equalsIgnoreCase("hol"))
											{
												ArrayList<String> camere=new ArrayList<String>();
												camere.add("living");
												camere.add("hol");
												goToRoom(omulet,camere);
												xx.add(350);
												yy.add(650);
												xx.add(350);
												yy.add(150);
												
												goOnInterface(xx, yy, omulet);
												positionPersonaInRoom("hol", omulet);

											}
				}
				else
					if (camera.equalsIgnoreCase("baie1"))
					{
						if (atribut.equalsIgnoreCase("baie2"))
						{
							ArrayList<String> camere=new ArrayList<String>();
							camere.add("baie1");
							camere.add("hol");
							camere.add("baie2");
							goToRoom(omulet,camere);
							xx.add(500);
							yy.add(650);
							xx.add(500);
							yy.add(400);
							xx.add(150);
							yy.add(400);
							
							goOnInterface(xx, yy, omulet);
							positionPersonaInRoom("baie2", omulet);
						}
						else
							if (atribut.equalsIgnoreCase("living"))
							{
								ArrayList<String> camere=new ArrayList<String>();
								camere.add("baie1");
								camere.add("living");
								goToRoom(omulet,camere);
								xx.add(500);
								yy.add(650);
								xx.add(350);
								yy.add(650);
								
								goOnInterface(xx, yy, omulet);
								positionPersonaInRoom("living", omulet);
							}
							else
								if (atribut.equalsIgnoreCase("bucatarie"))
								{
									ArrayList<String> camere=new ArrayList<String>();
									camere.add("baie1");
									camere.add("hol");
									camere.add("bucatarie");
									goToRoom(omulet,camere);
									xx.add(500);
									yy.add(650);
									xx.add(500);
									yy.add(150);
									xx.add(150);
									yy.add(150);
									
									goOnInterface(xx, yy, omulet);
									positionPersonaInRoom("bucatarie", omulet);
								}
								else
									if (atribut.equalsIgnoreCase("dormitor1"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("baie1");
										camere.add("dormitor1");
										goToRoom(omulet,camere);
										xx.add(500);
										yy.add(650);
										xx.add(800);
										yy.add(650);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("dormitor1", omulet);
									}
									else
										if (atribut.equalsIgnoreCase("dormitor2"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("baie1");
											camere.add("hol");
											camere.add("dormitor2");
											goToRoom(omulet,camere);
											xx.add(500);
											yy.add(650);
											xx.add(500);
											yy.add(400);
											xx.add(800);
											yy.add(400);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("dormitor2", omulet);
										}
										else
											if (atribut.equalsIgnoreCase("dormitor3"))
											{
												ArrayList<String> camere=new ArrayList<String>();
												camere.add("baie1");
												camere.add("hol");
												camere.add("dormitor3");
												goToRoom(omulet,camere);
												xx.add(500);
												yy.add(650);
												xx.add(500);
												yy.add(150);
												xx.add(800);
												yy.add(150);
												
												goOnInterface(xx, yy, omulet);
												positionPersonaInRoom("dormitor3", omulet);
											}
											else
												if (atribut.equalsIgnoreCase("hol"))
												{
													ArrayList<String> camere=new ArrayList<String>();
													camere.add("baie1");
													camere.add("hol");
													goToRoom(omulet,camere);
													xx.add(500);
													yy.add(650);
													xx.add(500);
													yy.add(150);
													
													goOnInterface(xx, yy, omulet);
													positionPersonaInRoom("hol", omulet);
												}
					}
					else
						if (camera.equalsIgnoreCase("dormitor1"))
						{
							if (atribut.equalsIgnoreCase("baie2"))
							{
								ArrayList<String> camere=new ArrayList<String>();
								camere.add("dormitor1");
								camere.add("dormitor2");
								camere.add("hol");
								camere.add("baie2");
								goToRoom(omulet,camere);
								xx.add(800);
								yy.add(650);
								xx.add(800);
								yy.add(400);
								xx.add(500);
								yy.add(400);
								xx.add(150);
								yy.add(400);
								
								goOnInterface(xx, yy, omulet);
								positionPersonaInRoom("baie2", omulet);
							}
							else
								if (atribut.equalsIgnoreCase("living"))
								{
									ArrayList<String> camere=new ArrayList<String>();
									camere.add("dormitor1");
									camere.add("baie1");
									camere.add("living");
									goToRoom(omulet,camere);
									xx.add(800);
									yy.add(650);
									xx.add(500);
									yy.add(650);
									xx.add(350);
									yy.add(650);
									
									goOnInterface(xx, yy, omulet);
									positionPersonaInRoom("living", omulet);
								}
								else
									if (atribut.equalsIgnoreCase("baie1"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("dormitor1");
										camere.add("baie1");
										goToRoom(omulet,camere);
										xx.add(800);
										yy.add(650);
										xx.add(500);
										yy.add(650);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("baie1", omulet);
									}
									else
										if (atribut.equalsIgnoreCase("bucatarie"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("dormitor1");
											camere.add("dormitor2");
											camere.add("hol");
											camere.add("bucatarie");
											goToRoom(omulet,camere);
											xx.add(800);
											yy.add(650);
											xx.add(800);
											yy.add(400);
											xx.add(350);
											yy.add(400);
											xx.add(350);
											yy.add(150);
											xx.add(150);
											yy.add(150);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("bucatarie", omulet);
										}
										else
											if (atribut.equalsIgnoreCase("dormitor2"))
											{
												ArrayList<String> camere=new ArrayList<String>();
												camere.add("dormitor1");
												camere.add("dormitor2");
												goToRoom(omulet,camere);
												xx.add(800);
												yy.add(650);
												xx.add(800);
												yy.add(400);
												
												goOnInterface(xx, yy, omulet);
												positionPersonaInRoom("dormitor2", omulet);
											}
											else
												if (atribut.equalsIgnoreCase("dormitor3"))
												{
													ArrayList<String> camere=new ArrayList<String>();
													camere.add("dormitor1");
													camere.add("dormitor2");
													camere.add("hol");
													camere.add("dormitor3");
													goToRoom(omulet,camere);
													xx.add(800);
													yy.add(650);
													xx.add(800);
													yy.add(400);
													xx.add(500);
													yy.add(400);
													xx.add(500);
													yy.add(150);
													xx.add(800);
													yy.add(150);
													
													goOnInterface(xx, yy, omulet);
													positionPersonaInRoom("dormitor3", omulet);
												}
												else
													if (atribut.equalsIgnoreCase("hol"))
													{
														ArrayList<String> camere=new ArrayList<String>();
														camere.add("dormitor1");
														camere.add("dormitor2");
														camere.add("hol");
														goToRoom(omulet,camere);
														xx.add(800);
														yy.add(650);
														xx.add(800);
														yy.add(400);
														xx.add(350);
														yy.add(400);
														
														goOnInterface(xx, yy, omulet);
														positionPersonaInRoom("hol", omulet);
													}
						}
						else
							if (camera.equalsIgnoreCase("dormitor2"))
							{
								if (atribut.equalsIgnoreCase("baie2"))
								{
									ArrayList<String> camere=new ArrayList<String>();
									camere.add("dormitor2");
									camere.add("hol");
									camere.add("baie2");
									goToRoom(omulet,camere);
									xx.add(800);
									yy.add(400);
									xx.add(350);
									yy.add(400);
									xx.add(150);
									yy.add(400);
									
									goOnInterface(xx, yy, omulet);
									positionPersonaInRoom("baie2", omulet);
								}
								else
									if (atribut.equalsIgnoreCase("living"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("dormitor2");
										camere.add("hol");
										camere.add("living");
										goToRoom(omulet,camere);
										xx.add(800);
										yy.add(400);
										xx.add(350);
										yy.add(400);
										xx.add(350);
										yy.add(650);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("living", omulet);
									
									}
									else
										if (atribut.equalsIgnoreCase("baie1"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("dormitor2");
											camere.add("hol");
											camere.add("baie1");
											goToRoom(omulet,camere);
											xx.add(800);
											yy.add(400);
											xx.add(500);
											yy.add(400);
											xx.add(500);
											yy.add(650);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("baie1", omulet);
											
										}
										else
											if (atribut.equalsIgnoreCase("dormitor1"))
											{
												ArrayList<String> camere=new ArrayList<String>();
												camere.add("dormitor2");
												camere.add("dormitor1");
												goToRoom(omulet,camere);
												xx.add(800);
												yy.add(400);
												xx.add(800);
												yy.add(650);
												
												goOnInterface(xx, yy, omulet);
												positionPersonaInRoom("dormitor1", omulet);
											}
											else
												if (atribut.equalsIgnoreCase("bucatarie"))
												{
													ArrayList<String> camere=new ArrayList<String>();
													camere.add("dormitor2");
													camere.add("hol");
													camere.add("bucatarie");
													goToRoom(omulet,camere);
													xx.add(800);
													yy.add(400);
													xx.add(350);
													yy.add(400);
													xx.add(350);
													yy.add(150);
													xx.add(150);
													yy.add(150);
													
													goOnInterface(xx, yy, omulet);
													positionPersonaInRoom("bucatarie", omulet);
												}
												else
													if (atribut.equalsIgnoreCase("dormitor3"))
													{
														ArrayList<String> camere=new ArrayList<String>();
														camere.add("dormitor2");
														camere.add("hol");
														camere.add("dormitor3");
														goToRoom(omulet,camere);
														xx.add(800);
														yy.add(400);
														xx.add(500);
														yy.add(400);
														xx.add(500);
														yy.add(150);
														xx.add(800);
														yy.add(150);
														
														goOnInterface(xx, yy, omulet);
														positionPersonaInRoom("dormitor3", omulet);
													}
													else
														if (atribut.equalsIgnoreCase("hol"))
														{
															ArrayList<String> camere=new ArrayList<String>();
															camere.add("dormitor2");
															camere.add("hol");
															goToRoom(omulet,camere);
															xx.add(800);
															yy.add(400);
															xx.add(350);
															yy.add(400);
															
															goOnInterface(xx, yy, omulet);
															positionPersonaInRoom("hol", omulet);
														}
							}
							else
								if (camera.equalsIgnoreCase("dormitor3"))
								{
									if (atribut.equalsIgnoreCase("baie2"))
									{
										ArrayList<String> camere=new ArrayList<String>();
										camere.add("dormitor3");
										camere.add("hol");
										camere.add("baie2");
										goToRoom(omulet,camere);
										xx.add(800);
										yy.add(150);
										xx.add(350);
										yy.add(150);
										xx.add(350);
										yy.add(400);
										xx.add(150);
										yy.add(400);
										
										goOnInterface(xx, yy, omulet);
										positionPersonaInRoom("baie2", omulet);
									}
									else
										if (atribut.equalsIgnoreCase("living"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("dormitor3");
											camere.add("hol");
											camere.add("living");
											goToRoom(omulet,camere);
											xx.add(800);
											yy.add(150);
											xx.add(350);
											yy.add(150);
											xx.add(350);
											yy.add(650);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("living", omulet);
										}
										else
											if (atribut.equalsIgnoreCase("baie1"))
											{
												ArrayList<String> camere=new ArrayList<String>();
												camere.add("dormitor3");
												camere.add("hol");
												camere.add("baie1");
												goToRoom(omulet,camere);
												xx.add(800);
												yy.add(150);
												xx.add(500);
												yy.add(150);
												xx.add(500);
												yy.add(650);
												
												goOnInterface(xx, yy, omulet);
												positionPersonaInRoom("baie1", omulet);
											}
											else
												if (atribut.equalsIgnoreCase("dormitor1"))
												{
													ArrayList<String> camere=new ArrayList<String>();
													camere.add("dormitor3");
													camere.add("hol");
													camere.add("dormitor2");
													camere.add("dormitor1");
													goToRoom(omulet,camere);
													xx.add(800);
													yy.add(150);
													xx.add(500);
													yy.add(150);
													xx.add(500);
													yy.add(400);
													xx.add(800);
													yy.add(400);
													xx.add(800);
													yy.add(650);
													
													goOnInterface(xx, yy, omulet);
													positionPersonaInRoom("dormitor1", omulet);
												}
												else
													if (atribut.equalsIgnoreCase("dormitor2"))
													{
														ArrayList<String> camere=new ArrayList<String>();
														camere.add("dormitor3");
														camere.add("hol");
														camere.add("dormitor2");
														goToRoom(omulet,camere);
														xx.add(800);
														yy.add(150);
														xx.add(500);
														yy.add(150);
														xx.add(500);
														yy.add(400);
														xx.add(800);
														yy.add(400);
														
														goOnInterface(xx, yy, omulet);
														positionPersonaInRoom("dormitor2", omulet);
													}
													else
														if (atribut.equalsIgnoreCase("bucatarie"))
														{
															ArrayList<String> camere=new ArrayList<String>();
															camere.add("dormitor3");
															camere.add("hol");
															camere.add("bucatarie");
															goToRoom(omulet,camere);
															xx.add(800);
															yy.add(150);
															xx.add(350);
															yy.add(150);
															xx.add(150);
															yy.add(150);
															
															goOnInterface(xx, yy, omulet);
															positionPersonaInRoom("bucatarie", omulet);
														}
														else
															if (atribut.equalsIgnoreCase("hol"))
															{
																ArrayList<String> camere=new ArrayList<String>();
																camere.add("dormitor3");
																camere.add("hol");
																goToRoom(omulet,camere);
																xx.add(800);
																yy.add(150);
																xx.add(350);
																yy.add(150);
																
																goOnInterface(xx, yy, omulet);
																positionPersonaInRoom("hol", omulet);
															}
								}
								else
									if (camera.equalsIgnoreCase("hol"))
									{
										if (atribut.equalsIgnoreCase("baie2"))
										{
											ArrayList<String> camere=new ArrayList<String>();
											camere.add("hol");
											camere.add("baie2");
											goToRoom(omulet,camere);
											xx.add(350);
											yy.add(400);
											xx.add(150);
											yy.add(400);
											
											goOnInterface(xx, yy, omulet);
											positionPersonaInRoom("baie2", omulet);
										}
										else
											if (atribut.equalsIgnoreCase("living"))
											{
												ArrayList<String> camere=new ArrayList<String>();
												camere.add("hol");
												camere.add("living");
												goToRoom(omulet,camere);
												xx.add(350);
												yy.add(400);
												xx.add(350);
												yy.add(650);
												
												goOnInterface(xx, yy, omulet);
												positionPersonaInRoom("living", omulet);
											}
											else
												if (atribut.equalsIgnoreCase("baie1"))
												{
													ArrayList<String> camere=new ArrayList<String>();
													camere.add("hol");
													camere.add("baie1");
													goToRoom(omulet,camere);
													xx.add(500);
													yy.add(400);
													xx.add(500);
													yy.add(650);
													
													goOnInterface(xx, yy, omulet);
													positionPersonaInRoom("baie1", omulet);
												}
												else
													if (atribut.equalsIgnoreCase("dormitor1"))
													{
														ArrayList<String> camere=new ArrayList<String>();
														camere.add("hol");
														camere.add("dormitor2");
														camere.add("dormitor1");
														goToRoom(omulet,camere);
														xx.add(500);
														yy.add(400);
														xx.add(800);
														yy.add(400);
														xx.add(800);
														yy.add(650);
														
														goOnInterface(xx, yy, omulet);
														positionPersonaInRoom("dormitor1", omulet);
													}
													else
														if (atribut.equalsIgnoreCase("dormitor2"))
														{
															ArrayList<String> camere=new ArrayList<String>();
															camere.add("hol");
															camere.add("dormitor2");
															goToRoom(omulet,camere);
															xx.add(500);
															yy.add(400);
															xx.add(800);
															yy.add(400);
															
															goOnInterface(xx, yy, omulet);
															positionPersonaInRoom("dormitor2", omulet);
														}
														else
															if (atribut.equalsIgnoreCase("dormitor3"))
															{
																ArrayList<String> camere=new ArrayList<String>();
																camere.add("hol");
																camere.add("dormitor3");
																goToRoom(omulet,camere);
																xx.add(500);
																yy.add(150);
																xx.add(800);
																yy.add(150);
																
																goOnInterface(xx, yy, omulet);
																positionPersonaInRoom("dormitor3", omulet);
															}
															else
																if (atribut.equalsIgnoreCase("bucatarie"))
																{
																	ArrayList<String> camere=new ArrayList<String>();
																	camere.add("hol");
																	camere.add("bucatarie");
																	goToRoom(omulet,camere);
																	xx.add(350);
																	yy.add(150);
																	xx.add(150);
																	yy.add(150);
																	
																	goOnInterface(xx, yy, omulet);
																	positionPersonaInRoom("bucatarie", omulet);
																	
																}
									}

	}
	
	/**
	 * actiunea pleaca
	 */
	public void goAway(String omulet)
	{
		if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
		{
			CreateScenarioPersons.omulet1.setPozitie("hol");
			HomeInterface.xDestOmulet1.add(450);
			HomeInterface.yDestOmulet1.add(150);
			HomeInterface.xDestOmulet1.add(450);
			HomeInterface.yDestOmulet1.add(-50);
			CreateScenarioPersons.omulet1.setPlecat(true);
		}
		else
			if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
			{
				CreateScenarioPersons.omulet2.setPozitie("hol");
				HomeInterface.xDestOmulet2.add(450);
				HomeInterface.yDestOmulet2.add(150);
				HomeInterface.xDestOmulet2.add(450);
				HomeInterface.yDestOmulet2.add(-50);
				CreateScenarioPersons.omulet2.setPlecat(true);
			}
			else
				if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
				{
					CreateScenarioPersons.omulet3.setPozitie("hol");
					HomeInterface.xDestOmulet3.add(450);
					HomeInterface.yDestOmulet3.add(150);
					HomeInterface.xDestOmulet3.add(450);
					HomeInterface.yDestOmulet3.add(-50);
					CreateScenarioPersons.omulet3.setPlecat(true);
				}
				else
					if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
					{
						CreateScenarioPersons.omulet4.setPozitie("hol");
						HomeInterface.xDestOmulet4.add(450);
						HomeInterface.yDestOmulet4.add(150);
						HomeInterface.xDestOmulet4.add(450);
						HomeInterface.yDestOmulet4.add(-50);
						CreateScenarioPersons.omulet4.setPlecat(true);
					}
		if (CreateScenarioPersons.omulet1.isPlecat() && CreateScenarioPersons.omulet2.isPlecat() && CreateScenarioPersons.omulet3.isPlecat() && CreateScenarioPersons.omulet4.isPlecat())
		{
			HomeInterface.TIMER_INTERVAL=100;
			TimerBean.interval=100;
		}
	
		
	}
	/**
	 * actiunea vine
	 */
	public void comeHome(String omulet)
	{
		HomeInterface.TIMER_INTERVAL=1000;
		TimerBean.interval=1000;

		if (CreateScenarioPersons.omulet1.getNume().equalsIgnoreCase(omulet))
		{
			CreateScenarioPersons.omulet1.setPozitie("hol");
			HomeInterface.xDestOmulet1.add(450);
			HomeInterface.yDestOmulet1.add(150);
			positionPersonaInRoom("hol", omulet);
			CreateScenarioPersons.omulet1.setPlecat(false);
		}
		else
			if (CreateScenarioPersons.omulet2.getNume().equalsIgnoreCase(omulet))
			{
				CreateScenarioPersons.omulet2.setPozitie("hol");
				HomeInterface.xDestOmulet2.add(450);
				HomeInterface.yDestOmulet2.add(150);
				positionPersonaInRoom("hol", omulet);
				CreateScenarioPersons.omulet2.setPlecat(false);
			}
			else
				if (CreateScenarioPersons.omulet3.getNume().equalsIgnoreCase(omulet))
				{
					CreateScenarioPersons.omulet3.setPozitie("hol");
					HomeInterface.xDestOmulet3.add(450);
					HomeInterface.yDestOmulet3.add(150);
					positionPersonaInRoom("hol", omulet);
					CreateScenarioPersons.omulet3.setPlecat(false);
				}
				else
					if (CreateScenarioPersons.omulet4.getNume().equalsIgnoreCase(omulet))
					{
						CreateScenarioPersons.omulet4.setPozitie("hol");
						HomeInterface.xDestOmulet4.add(450);
						HomeInterface.yDestOmulet4.add(150);
						positionPersonaInRoom("hol", omulet);
						CreateScenarioPersons.omulet4.setPlecat(false);
					}
		Simulator.senzorMiscareHol.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
	}
	
	/**
	 * actiunea merge la WC
	 */
	public void goToWC(int i,String omulet)
	{
		String camera=getPersonsRoom(omulet);
		ora_sfarsit.add(aux.getEndHours(i));
		min_sfarsit.add(aux.getEndMinutes(i));
		sec_sfarsit.add(aux.getEndSeconds(i));
		cameraConsum.add(camera);
		ceSpala.add("wc");
		if (camera.equalsIgnoreCase("baie1"))
		{
			float consum_total=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "WC");
			consum_apa.add(consum_total);
			Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()+consum_total);
			Simulator.senzorMiscareBaie1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
			CreateHome.casa.wc1.setStare(true);
		}
		else
			if (camera.equalsIgnoreCase("baie2"))
			{
				float consum_total=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "WC");
				consum_apa.add(consum_total);
				Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()+consum_total);
				Simulator.senzorMiscareBaie2.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
				CreateHome.casa.wc2.setStare(true);
			}
	}
	
	/**
	 * actiunea spala
	 */
	public void wash(int i,String omulet)
	{
		ora_sfarsit.add(aux.getEndHours(i));
		min_sfarsit.add(aux.getEndMinutes(i));
		sec_sfarsit.add(aux.getEndSeconds(i));
		String camera=getPersonsRoom(omulet);
		String atribut=aux.getAttribute(i);
		cameraConsum.add(camera);
		ceSpala.add(atribut);
		if (camera.equalsIgnoreCase("baie1"))
		{
			float consum_total=DataProcessing.getWaterConsumption(Simulator.connection, "apa", atribut);
			consum_apa.add(consum_total);
			Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()+consum_total);
			Simulator.senzorMiscareBaie1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
			if (atribut.equalsIgnoreCase("dus") || atribut.equalsIgnoreCase("picioare"))
				CreateHome.casa.robinetVana.setStare(true);
			else
				if (!atribut.equalsIgnoreCase("haine"))
					CreateHome.casa.robinetBaie1.setStare(true);
		}
		else
			if (camera.equalsIgnoreCase("baie2"))
			{
				float consum_total=DataProcessing.getWaterConsumption(Simulator.connection, "apa", atribut);
				consum_apa.add(consum_total);
				Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()+consum_total);
				Simulator.senzorMiscareBaie2.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
				if (!atribut.equalsIgnoreCase("haine"))
					CreateHome.casa.robinetB2.setStare(true);
			}
		if (atribut.equalsIgnoreCase("haine"))
		{
			ora_sf.add(aux.getEndHours(i));
			min_sf.add(aux.getEndMinutes(i));
			sec_sf.add(aux.getEndSeconds(i));
			consum_curent.add(DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "masina de spalat vase", "-").get(0));
			Simulator.senzorCurent.setPower(DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "masina de spalat vase", "-").get(0));
			CreateHome.casa.masina.setStare(true);
			ceFoloseste.add("masina de spalaat");
		}
	}
	
	/**
	 * actiunea porneste
	 */
	public void turnOn(int i,String omulet)
	{
		String camera=getPersonsRoom(omulet);
		String atribut=aux.getAttribute(i);
		if (atribut.equalsIgnoreCase("aragaz"))
		{
			Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()+DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie"));
			CreateHome.casa.aragaz.setStare(true);

		}
		else
			if (atribut.equalsIgnoreCase("aer conditionat"))
			{
				float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "aer conditionat", "-").get(0);
				Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
				aer_conditionat=true;
				//raceste cu 5 grade
				Simulator.senzorTemperatura.setPower(Simulator.senzorTemperatura.getPower()-5);
				CreateHome.casa.aer.setStare(true);
			}
			else
				if (atribut.equalsIgnoreCase("calculator"))
				{
					float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "computer", "pornit").get(0);
					Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
					CreateHome.casa.calcL.setStare(true);
				}
				else
					if (atribut.equalsIgnoreCase("televizor"))
					{
						float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "televizor", "pornit(imagine luminozitate normala)").get(0);
						Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
						CreateHome.casa.tv.setStare(true);
					}
					else
						if (atribut.equalsIgnoreCase("bec"))
						{
							float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "veioza", "pornit").get(0);
							Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
							setLamp(camera, true);
						}
						else
							if (atribut.equalsIgnoreCase("masina de spalat"))
							{
								float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "masina de spalat vase", "-").get(0);
								Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
								consum=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "haine");
								if (camera.equalsIgnoreCase("baie1"))
									Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()+consum);
								else
									if (camera.equalsIgnoreCase("baie2"))
									{
										Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()+consum);
										CreateHome.casa.masina.setStare(true);
									}
							}
		modifyMovementSensor(camera);
	}
	
	/**
	 * actiunea opreste
	 */
	public void turnOff(int i,String omulet)
	{
		String camera=getPersonsRoom(omulet);
		String atribut=aux.getAttribute(i);
		if (atribut.equalsIgnoreCase("aragaz"))
		{
			Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()-DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie"));
			CreateHome.casa.aragaz.setStare(false);
		}
		else
			if (atribut.equalsIgnoreCase("aer conditionat"))
			{
				float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "aer conditionat", "-").get(0);
				Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-consum);
				aer_conditionat=false;
				//reincalzeste cu 5 grade
				Simulator.senzorTemperatura.setPower(Simulator.senzorTemperatura.getPower()+5);
				CreateHome.casa.aer.setStare(false);
			}
			else
				if (atribut.equalsIgnoreCase("calculator"))
				{
					float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "computer", "pornit").get(0);
					Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-consum);
					CreateHome.casa.calcL.setStare(false);
				}
				else
					if (atribut.equalsIgnoreCase("televizor"))
					{
						float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "televizor", "pornit(imagine luminozitate normala)").get(0);
						Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-consum);
						CreateHome.casa.tv.setStare(false);
					}
					else
						if (atribut.equalsIgnoreCase("bec"))
						{
							float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "veioza", "pornit").get(0);
							Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-consum);
							setLamp(camera, false);
						}
						else
							if (atribut.equalsIgnoreCase("masina de spalat"))
							{
								float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "masina de spalat vase", "-").get(0);
								Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-consum);
								consum=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "haine");
								if (camera.equalsIgnoreCase("baie1"))
									Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()-consum);
								else
									if (camera.equalsIgnoreCase("baie2"))
									{
										Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()-consum);
										CreateHome.casa.masina.setStare(false);
									}
							}
		modifyMovementSensor(camera);
	}
	
	/**
	 * actiunea foloseste
	 */
	public void use(int i,String omulet)
	{

		String camera=getPersonsRoom(omulet);
		String atribut=aux.getAttribute(i);
		if (atribut.equalsIgnoreCase("aragaz"))
		{
			ora_sf_gaz.add(aux.getEndHours(i));
			min_sf_gaz.add(aux.getEndMinutes(i));
			sec_sf_gaz.add(aux.getEndSeconds(i));
			ultima_gaz.add(DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie"));
			Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()+DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie"));
			CreateHome.casa.aragaz.setStare(true);
		}
		else
		{
			ceFoloseste.add(atribut);
			if (atribut.equalsIgnoreCase("aer conditionat"))
			{

				float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "aer conditionat", "-").get(0);
				ora_sf.add(aux.getEndHours(i));
				min_sf.add(aux.getEndMinutes(i));
				sec_sf.add(aux.getEndSeconds(i));
				consum_curent.add(consum);
				Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
				ora_aer=aux.getEndHours(i);
				min_aer=aux.getEndMinutes(i);
				sec_aer=aux.getEndSeconds(i);
				Simulator.senzorTemperatura.setPower(Simulator.senzorTemperatura.getPower()-5);
				CreateHome.casa.aer.setStare(true);
			}
			else
				if (atribut.equalsIgnoreCase("calculator"))
				{
					float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "computer", "pornit").get(0);
					ora_sf.add(aux.getEndHours(i));
					min_sf.add(aux.getEndMinutes(i));
					sec_sf.add(aux.getEndSeconds(i));
					consum_curent.add(consum);
					Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
					CreateHome.casa.calcL.setStare(true);
				}
				else
					if (atribut.equalsIgnoreCase("televizor"))
					{
						float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "televizor", "pornit(imagine luminozitate normala)").get(0);
						ora_sf.add(aux.getEndHours(i));
						min_sf.add(aux.getEndMinutes(i));
						sec_sf.add(aux.getEndSeconds(i));
						consum_curent.add(consum);
						Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
						CreateHome.casa.tv.setStare(true);
					}
					else
						if (atribut.equalsIgnoreCase("bec"))
						{
							float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "veioza", "pornit").get(0);
							ora_sf.add(aux.getEndHours(i));
							min_sf.add(aux.getEndMinutes(i));
							sec_sf.add(aux.getEndSeconds(i));
							consum_curent.add(consum);
							Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
							setLamp(camera, true);
							cameraBec=camera;
						}
						else
							if (atribut.equalsIgnoreCase("masina de spalat"))
							{
								float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "masina de spalat vase", "-").get(0);
								ora_sf.add(aux.getEndHours(i));
								min_sf.add(aux.getEndMinutes(i));
								sec_sf.add(aux.getEndSeconds(i));
								consum_curent.add(consum);
								Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
								consum=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "haine");
								ora_masina=aux.getEndHours(i);
								min_masina=aux.getEndMinutes(i);
								sec_masina=aux.getEndSeconds(i);
								cameraOmulet=camera;
								if (camera.equalsIgnoreCase("baie1"))
									Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()+consum);
								else
									if (camera.equalsIgnoreCase("baie2"))
									{
										Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()+consum);
										CreateHome.casa.masina.setStare(true);
									}
								
							}
							else
								if (atribut.equalsIgnoreCase("frigider"))
								{

									float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "frigider", "pornit, nu raceste cu usa deschisa").get(0);
									ora_sf.add(aux.getEndHours(i));
									min_sf.add(aux.getEndMinutes(i));
									sec_sf.add(aux.getEndSeconds(i));
									consum_curent.add(consum);
									Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
									CreateHome.casa.frigi.setStare(true);
								}
		}
		modifyMovementSensor(camera);
	}
	
	/**
	 * actiunea seteaza
	 */
	public void set(int i,String omulet)
	{
		String camera=getPersonsRoom(omulet);
		String atribut=aux.getAttribute(i);
		String setare=aux.getSetting(i);
		if (atribut.equalsIgnoreCase("aragaz"))
		{
			ultim_gaz=DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie");
			Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()+(DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie")));
			CreateHome.casa.aragaz.setStare(true);
		}
		else
			if (atribut.equalsIgnoreCase("aer conditionat"))
			{
				float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "aer conditionat", "-").get(0);
				ultima_curent.add(consum);
				Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
				CreateHome.casa.aer.setStare(true);
			}
			else
				if (atribut.equalsIgnoreCase("calculator"))
				{
					float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "computer", "pornit").get(0);
					ultima_curent.add(consum);
					Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
					CreateHome.casa.calcL.setStare(true);
				}
				else
					if (atribut.equalsIgnoreCase("televizor"))
					{
						float consum;
						if (setare.equalsIgnoreCase("mica"))
							consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "televizor", "pornit(imagine luminozitate mica)").get(0);
						else
							if (setare.equalsIgnoreCase("mare"))
								consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "televizor", "pornit(imagine luminozitate mare)").get(0);
							else
								consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "televizor", "pornit(imagine luminozitate normala)").get(0);
						ultima_curent.add(consum);
						Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
						CreateHome.casa.tv.setStare(true);
					}
					else
						if (atribut.equalsIgnoreCase("bec"))
						{
							float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "veioza", "pornit").get(0);
							ultima_curent.add(consum);
							Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
							setLamp(camera, true);
						}
						else
							if (atribut.equalsIgnoreCase("masina de spalat"))
							{
								float consum=DataProcessing.getCurrentConsumption(Simulator.connection, "electricitate", "masina de spalat vase", "-").get(0);
								ultima_curent.add(consum);
								Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()+consum);
								CreateHome.casa.masina.setStare(true);
							}
		modifyMovementSensor(camera);
	}
	
	/**
	 * decide ce senzori trebuie sa-si modifice starea in functie de actiunea de la linia i
	 */
	public void process(int i)
	{
		String actiune=aux.getAction(i);
		String omulet=aux.getPerson(i);
		if (actiune.equalsIgnoreCase("trezeste"))
		{
			wakeUp(omulet);
		}
		else
			if (actiune.equalsIgnoreCase("culca"))
			{
				goToSleep(omulet);
			}
			else
				if (actiune.equalsIgnoreCase("merge"))
				{
					go(i,omulet);
				}
				else
					if (actiune.equalsIgnoreCase("pleaca"))
					{
						goAway(omulet);
					}
					else 
						if (actiune.equalsIgnoreCase("vine"))
						{
							comeHome(omulet);
						}
						else
							if (actiune.equalsIgnoreCase("mananca"))
							{
								ora_sf_mancare=aux.getEndHours(i);
								min_sf_mancare=aux.getEndMinutes(i);
								sec_sf_mancare=aux.getEndSeconds(i);

								Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
							}
							else
								if (actiune.equalsIgnoreCase("bea"))
								{
									float consum=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "bea");
									ultima_apa.add(consum);
									ultima_camera.add("bucatarie");
									Simulator.senzorApaBuc.setPower(Simulator.senzorApaBuc.getPower()+consum);
									Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
									CreateHome.casa.robinetBuc.setStare(true);
								}
								else
									if (actiune.equalsIgnoreCase("gateste"))
									{
										Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()+DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie"));
										ultima_gaz.add(DataProcessing.getGassConsumption(Simulator.connection, "gaz", "valoare medie"));
										ora_sf_gaz.add(aux.getEndHours(i));
										min_sf_gaz.add(aux.getEndMinutes(i));
										sec_sf_gaz.add(aux.getEndSeconds(i));
										Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
										CreateHome.casa.aragaz.setStare(true);
									}
									else
										if (actiune.equalsIgnoreCase("merge_la_WC"))
										{
											goToWC(i,omulet);
										}
										else
											if (actiune.equalsIgnoreCase("spala"))
											{
												wash(i,omulet);

											}
											else
												if (actiune.equalsIgnoreCase("porneste"))
												{
													turnOn(i,omulet);
												}
												else 
													if (actiune.equalsIgnoreCase("opreste"))
													{
														turnOff(i,omulet);
													}
													else
														if (actiune.equalsIgnoreCase("foloseste"))
														{
															use(i,omulet);
														}
														else
															if (actiune.equalsIgnoreCase("seteaza"))
															{
																set(i,omulet);
															}
	}
	
	/**
	 * seteaza viteza simulatorului si simulatorului grafic
	 */
	public void setSpeed()
	{
		if ((CreateScenarioPersons.omulet1.isPlecat()||CreateScenarioPersons.omulet1.isDoarme())&& (CreateScenarioPersons.omulet2.isPlecat()||CreateScenarioPersons.omulet2.isDoarme()) && (CreateScenarioPersons.omulet3.isPlecat()||CreateScenarioPersons.omulet3.isDoarme())&&(CreateScenarioPersons.omulet4.isPlecat()||CreateScenarioPersons.omulet4.isDoarme()))
		{
			HomeInterface.TIMER_INTERVAL=100;
			TimerBean.interval=100;
		}
		else
		{
			HomeInterface.TIMER_INTERVAL=1000;
			TimerBean.interval=1000;
		}
	}

	/**
	 * citeste scenariul
	 */
	@Override
	public void timeElapsed(TimerEvent evt) {
		// TODO Auto-generated method stub
		int ora=TimerEvent.now.getHours();
		int min=TimerEvent.now.getMinutes();
		int sec=TimerEvent.now.getSeconds();

		Simulator.senzorMiscareBaie1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareBaie2.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareLiving.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareDormitor1.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareDormitor2.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareDormitor3.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
		Simulator.senzorMiscareHol.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));

		//intre 0-7 temperatura=20 grade, in rest temperatura=25 grade
		if (!aer_conditionat)
			if (ora<7)
				Simulator.senzorTemperatura.setPower(20);
			else
				Simulator.senzorTemperatura.setPower(23);
		if (i<n)
		{
			setSpeed();

			int oraScenariu=aux.getHour(i);
			int minScenariu=aux.getMinute(i);
			int secScenariu=aux.getSeconde(i);

			//foloseste aer conditionat
			if (ora_aer!=-1 && min_aer!=-1 && sec_aer!=-1)
			{
				if ((ora>ora_aer) || (ora==ora_aer && min>min_aer) || (ora==ora_aer && min==min_aer && sec>=sec_aer))
				{
					Simulator.senzorTemperatura.setPower(Simulator.senzorTemperatura.getPower()+5);
					ora_aer=-1;
					min_aer=-1;
					sec_aer=-1;
					CreateHome.casa.aer.setStare(false);
				}
			}
			
			//foloseste masina de spalat
			if (ora_masina!=-1 && min_masina!=-1 && sec_masina!=-1)
			{
				if ((ora>ora_masina) || (ora==ora_masina && min>min_masina) || (ora==ora_masina && min==min_masina && sec>=sec_masina))
				{
					float consum=DataProcessing.getWaterConsumption(Simulator.connection, "apa", "haine");
					if (cameraOmulet.equalsIgnoreCase("baie1"))
						Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()-consum);
					else
						if (cameraOmulet.equalsIgnoreCase("baie2"))
							Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()-consum);
					ora_masina=-1;
					min_masina=-1;
					sec_masina=-1;
					CreateHome.casa.masina.setStare(false);
				}
			}
			
			//mananca
			if (ora_sf_mancare!=-1 && min_sf_mancare!=-1 && sec_sf_mancare!=-1)
			{
				if (ora>ora_sf_mancare)
				{
					Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
					ora_sf_mancare=-1;
					min_sf_mancare=-1;
					sec_sf_mancare=-1;
				}
				else
					if (ora==ora_sf_mancare && min>min_sf_mancare)
					{
						Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
						ora_sf_mancare=-1;
						min_sf_mancare=-1;
						sec_sf_mancare=-1;
					}
					else
						if (ora==ora_sf_mancare && min==min_sf_mancare && sec>=sec_sf_mancare)
						{
							Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "sta"));
							ora_sf_mancare=-1;
							min_sf_mancare=-1;
							sec_sf_mancare=-1;
						}
						else
						{
							Simulator.senzorMiscareBucatarie.setPower(DataProcessing.getMovement(Simulator.connection, "senzor_miscare", "misca"));
						}
			}

			//foloseste aragaza de la ora x la ora_sf_gaz
			for (int index=0; index<ultima_gaz.size(); index++)
			{
				if ((ora>ora_sf_gaz.get(index)) || (ora==ora_sf_gaz.get(index) && min>min_sf_gaz.get(index)) || (ora==ora_sf_gaz.get(index) && min==min_sf_gaz.get(index) && sec>=sec_sf_gaz.get(index)))
				{
					Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()-ultima_gaz.get(index));
					ultima_gaz.remove(index);
					ora_sf_gaz.remove(index);
					min_sf_gaz.remove(index);
					sec_sf_gaz.remove(index);
					index--;
					CreateHome.casa.aragaz.setStare(false);
				}
				
			}
			
			if (ultim_gaz!=0)
			{
				Simulator.senzorGaz.setPower(Simulator.senzorGaz.getPower()-ultim_gaz);
				ultim_gaz=0;
				CreateHome.casa.aragaz.setStare(false);
			}
			
			//bea
			for (int index=0; index<ultima_apa.size(); index++)
			{
				if (ultima_camera.get(index).equalsIgnoreCase("baie1"))
				{
					Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()-ultima_apa.get(index));
					ultima_apa.remove(index);
					ultima_camera.remove(index);
					index--;
					CreateHome.casa.robinetBaie1.setStare(false);
				}
				else
					if (ultima_camera.get(index).equalsIgnoreCase("baie2"))
					{
						Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()-ultima_apa.get(index));
						ultima_apa.remove(index);
						ultima_camera.remove(index);
						index--;
						CreateHome.casa.robinetB2.setStare(false);
					}
					else
						if (ultima_camera.get(index).equalsIgnoreCase("bucatarie"))
						{
							Simulator.senzorApaBuc.setPower(Simulator.senzorApaBuc.getPower()-ultima_apa.get(index));
							ultima_apa.remove(index);
							ultima_camera.remove(index);
							index--;
							CreateHome.casa.robinetBuc.setStare(false);
						}
			}

			//spala/foloseste masina de spala de la ora x la ora_sfarsit
			for (int index=0; index<consum_apa.size(); index++)
			{

				if ((ora>ora_sfarsit.get(index)) || (ora==ora_sfarsit.get(index) && min>min_sfarsit.get(index)) || (ora==ora_sfarsit.get(index) && min==min_sfarsit.get(index) && sec>=sec_sfarsit.get(index)))
				{
					if (cameraConsum.get(index).equalsIgnoreCase("baie1"))
					{
						Simulator.senzorApaBaie1.setPower(Simulator.senzorApaBaie1.getPower()-consum_apa.get(index));
						if (ceSpala.get(index).equalsIgnoreCase("wc"))
							CreateHome.casa.wc1.setStare(false);
						else
							if (ceSpala.get(index).equalsIgnoreCase("dus") || ceSpala.get(index).equalsIgnoreCase("picioare"))
								CreateHome.casa.robinetVana.setStare(false);
							else
								if(ceSpala.get(index).equalsIgnoreCase("haine"))
									CreateHome.casa.masina.setStare(false);
								else
										CreateHome.casa.robinetBaie1.setStare(false);
						ceSpala.remove(index);
						consum_apa.remove(index);
						ora_sfarsit.remove(index);
						min_sfarsit.remove(index);
						sec_sfarsit.remove(index);
						cameraConsum.remove(index);
						index--;
					}
					else
						if (cameraConsum.get(index).equalsIgnoreCase("baie2"))
						{
							Simulator.senzorApaBaie2.setPower(Simulator.senzorApaBaie2.getPower()-consum_apa.get(index));
							if (ceSpala.get(index).equalsIgnoreCase("wc"))
								CreateHome.casa.wc2.setStare(false);
							else
								if (ceSpala.get(index).equalsIgnoreCase("dus") || ceSpala.get(index).equalsIgnoreCase("picioare"))
									CreateHome.casa.robinetVana.setStare(false);
								if(ceSpala.get(index).equalsIgnoreCase("haine"))
									CreateHome.casa.masina.setStare(false);
								else
										CreateHome.casa.robinetB2.setStare(false);
							ceSpala.remove(index);
							consum_apa.remove(index);
							ora_sfarsit.remove(index);
							min_sfarsit.remove(index);
							sec_sfarsit.remove(index);
							cameraConsum.remove(index);
							index--;
						}
						else
							if (cameraConsum.get(index).equalsIgnoreCase("bucatarie"))
							{
								Simulator.senzorApaBuc.setPower(Simulator.senzorApaBuc.getPower()-consum_apa.get(index));
								ceSpala.remove(index);
								consum_apa.remove(index);
								ora_sfarsit.remove(index);
								min_sfarsit.remove(index);
								sec_sfarsit.remove(index);
								cameraConsum.remove(index);
								index--;
							}
				}
			}
			
			
			for (int index=0; index<ultima_curent.size(); index++)
			{
				Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-ultima_curent.get(index));
				ultima_curent.remove(index);
				index--;
			}
			
			//foloseste un aparat de la ora x la ora_sf
			for (int index=0; index<consum_curent.size(); index++)
			{
				if ((ora>ora_sf.get(index))|| (ora==ora_sf.get(index) && min>min_sf.get(index)) || (ora==ora_sf.get(index) && min==min_sf.get(index) && sec>=sec_sf.get(index)))
				{
					Simulator.senzorCurent.setPower(Simulator.senzorCurent.getPower()-consum_curent.get(index));
					if (ceFoloseste.get(index).equalsIgnoreCase("aer conditionat"))
						CreateHome.casa.aer.setStare(false);
					else
						if (ceFoloseste.get(index).equalsIgnoreCase("aragaz"))
							CreateHome.casa.aragaz.setStare(false);
						else
							if (ceFoloseste.get(index).equalsIgnoreCase("calculator"))
								CreateHome.casa.calcL.setStare(false);
							else
								if (ceFoloseste.get(index).equalsIgnoreCase("televizor"))
									CreateHome.casa.tv.setStare(false);
								else
									if (ceFoloseste.get(index).equalsIgnoreCase("masina de spalat"))
										CreateHome.casa.masina.setStare(false);
									else
										if (ceFoloseste.get(index).equalsIgnoreCase("frigider"))
											CreateHome.casa.frigi.setStare(false);
										else
											if (ceFoloseste.get(index).equalsIgnoreCase("bec"))
												setLamp(cameraBec, false);
					ceFoloseste.remove(index);
					consum_curent.remove(index);
					ora_sf.remove(index);
					min_sf.remove(index);
					sec_sf.remove(index);
					index--;
				}
			}


			while (ora==oraScenariu && min==minScenariu && (sec>=30) && (secScenariu>=30 && secScenariu<60))
			{
				HomeInterface.TIMER_INTERVAL=1000;
				TimerBean.interval=1000;
				process(i);
				//skip to next line
				i++;
				if (i<n)
				{
					oraScenariu=aux.getHour(i);
					minScenariu=aux.getMinute(i);
					secScenariu=aux.getSeconde(i);
				}
				else
					if (i==n)
					{
						oraScenariu=0;
						minScenariu=0;
						secScenariu=0;
					}
			}//while
			
			while (ora==oraScenariu && min==minScenariu && (sec<30) && (secScenariu>=0 && secScenariu<30))
			{
				HomeInterface.TIMER_INTERVAL=1000;
				TimerBean.interval=1000;
				process(i);
				//skip to next line
				i++;
				if (i<n)
				{
					oraScenariu=aux.getHour(i);
					minScenariu=aux.getMinute(i);
					secScenariu=aux.getSeconde(i);
				}
				else
					if (i==n)
					{
						oraScenariu=0;
						minScenariu=0;
						secScenariu=0;
					}

			}
		}//end if
		else
			if (i>=n)
			{
				HomeInterface.TIMER_INTERVAL=100;
				TimerBean.interval=100;
			}
	}
}